package com.yfp.group.controller;

import com.yfp.common.core.domain.R;
import com.yfp.common.core.web.controller.BaseController;
import com.yfp.group.service.WxUserService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * 微信用户相关操作
 *
 *
 * @version 1.0
 * @date 2024-08-10 9:53
 */
@RestController
@RequestMapping("/wx")
@Tag(name = "微信用户相关操作")
public class WxUserController extends BaseController {

    @Resource
    private WxUserService wxUserService;

    @GetMapping("/appId/info")
    @Operation(summary = "h5-获取微信应用的appId", description = "获取微信应用的appId")
    public R<String> appIdInfo() {
        String appIdInfo = wxUserService.appIdInfo();
        return R.ok(appIdInfo);
    }

    @GetMapping("/user/info")
    @Operation(summary = "h5-获取用户的openId", description = "获取用户微信的信息")
    public R<Map<String, Object>> userInfo(@RequestParam("wxCode") String wxCode) {
        Map<String, Object> userInfo = wxUserService.userInfo(wxCode);
        return R.ok(userInfo);
    }
}
